/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Example.java
 *
 * Created on Feb 10, 2011, 4:40:49 PM
 */

package forms;

import beans.Barrio;
import beans.Boliche;
import beans.Profesion;
import beans.Socio;
import bussines.negocio.SocioBussines;
import javax.swing.JOptionPane;
import managers.ManagerSocio;

public class CargarSocio extends javax.swing.JFrame {

    private SocioBussines socioBussines = new SocioBussines();
    private Socio socio = null;
    private boolean isEdit = false;

    public boolean isIsEdit() {
        return isEdit;
    }

    public void setIsEdit(boolean isEdit) {
        this.isEdit = isEdit;
    }

    CargarSocio(Socio socio) {
        initComponents();
        this.setVisible(false);
        this.setSocio(socio);
        cargarCombos();
        txt_apellido.setText(socio.getApellido());
        txt_nombre.setText(socio.getNombre());
        txt_telefono.setText(socio.getTelefono());
        txt_legajo.setText(socio.getLegajo());
        date_fecha_nacimiento.setDate(socio.getFechaNacimiento());
        if(socio.getSexo().equalsIgnoreCase("M")){
            rbt_masculino.setSelected(true);
            rbt_femenino.setSelected(false);
        }else{
            rbt_femenino.setSelected(true);
            rbt_masculino.setSelected(false);
        }
        txt_direccion.setText(socio.getDireccion());
        txt_mail.setText(socio.getMail());

        //Carga de combo de barrios
        cmb_barrio.removeAllItems();
        cmb_barrio.addItem(socio.getBarrio());
        Barrio[] barrios = getGestor().getBarrios();
        for(int i=0;i<barrios.length;i++){
            if(!socio.getBarrio().getNombre().equalsIgnoreCase(barrios[i].getNombre())){
                cmb_barrio.addItem(barrios[i]);
            }
        }

        //Carga de combo de Profesiones
        cmb_profesion.removeAllItems();
        cmb_profesion.addItem(socio.getEstudio());
        Profesion[] profesion = getGestor().getProfesion();
        for(int i = 0; i<profesion.length;i++){
            if(!socio.getEstudio().getNombre().equalsIgnoreCase(profesion[i].getNombre())){
                cmb_profesion.addItem(profesion[i]);
            }
        }

        //Carga de combo de motivos socio
        cmb_motivo_socio.removeAllItems();
        cmb_motivo_socio.addItem(socio.getRazonSocio());
        if(!socio.getRazonSocio().equalsIgnoreCase("CONSUMIDOR")){
            cmb_motivo_socio.addItem("CONSUMIDOR");
        }
        if(!socio.getRazonSocio().equalsIgnoreCase("CONVOCANTE")){
            cmb_motivo_socio.addItem("CONVOCANTE");
        }
        if(!socio.getRazonSocio().equalsIgnoreCase("RELEVANTE")){
            cmb_motivo_socio.addItem("RELEVANTE");
        }

        //Carga de combo de avisar cumpleaños
        cmb_cumpleano_socio.removeAllItems();
        if(socio.getAvisarPorCumpleagnos().equalsIgnoreCase("S")){
            cmb_cumpleano_socio.addItem("SI");
            cmb_cumpleano_socio.addItem("NO");
        }else{
            cmb_cumpleano_socio.addItem("NO");
            cmb_cumpleano_socio.addItem("SI");
        }

        //Carga de combo de Boliches
        getCmb_boliche().removeAllItems();
        getCmb_boliche().addItem(socio.getBoliche());
        Boliche[] boliche = getGestor().getBoliche();
        for(int i = 0; i<boliche.length;i++){
            if(!socio.getBoliche().getNombre().equalsIgnoreCase(boliche[i].getNombre())){
                getCmb_boliche().addItem(boliche[i]);
            }
        }

    }

	public Socio getSocio() {
		return socio;
	}

	public void setSocio(Socio socio) {
		this.socio = socio;
	}



    public boolean validarSiguiente(){
        boolean valida = true;
        if(getTxt_legajo().getText().toString().equalsIgnoreCase("")){
           JOptionPane.showMessageDialog(null, "Debe ingresar el legajo!", "Error", JOptionPane.OK_OPTION);
           getTxt_legajo().requestFocus();
           valida = false;
           return valida;
       }else if(getTxt_nombre().getText().toString().equalsIgnoreCase("")){
           JOptionPane.showMessageDialog(null, "Debe ingresar el nombre!", "Error", JOptionPane.OK_OPTION);
            getTxt_nombre().requestFocus();
           valida = false;
       }else if(getTxt_apellido().getText().toString().equalsIgnoreCase("")){
           JOptionPane.showMessageDialog(null, "Debe ingresar el apellido!", "Error", JOptionPane.OK_OPTION);
            getTxt_apellido().requestFocus();
           valida = false;
       }else if(getDate_fecha_nacimiento().getDate()==null){
           JOptionPane.showMessageDialog(null, "Debe ingresar la fecha de nacimiento!", "Error", JOptionPane.OK_OPTION);
           valida = false;
       }else if(!rbt_masculino.isSelected() && !rbt_femenino.isSelected()){
           JOptionPane.showMessageDialog(null, "Debe ingresar el sexo!", "Error", JOptionPane.OK_OPTION);
           valida = false;
       }else if(getTxt_telefono().getText().toString().equalsIgnoreCase("")){
           JOptionPane.showMessageDialog(null, "Debe ingresar el teléfono!", "Error", JOptionPane.OK_OPTION);
            getTxt_telefono().requestFocus();
           valida = false;
       }else if(getTxt_direccion().getText().toString().equalsIgnoreCase("")){
           JOptionPane.showMessageDialog(null, "Debe ingresar la dirección!", "Error", JOptionPane.OK_OPTION);
            getTxt_direccion().requestFocus();
           valida = false;
       }else if(getTxt_mail().getText().toString().equalsIgnoreCase("")){
           JOptionPane.showMessageDialog(null, "Debe ingresar un mail!", "Error", JOptionPane.OK_OPTION);
            getTxt_mail().requestFocus();
           valida = false;
       }else if(!txt_mail.getText().contains("@")){
           JOptionPane.showMessageDialog(null, "Debe ingresar un mail correcto!", "Error", JOptionPane.OK_OPTION);
            getTxt_mail().requestFocus();
           valida = false;
       }else if(!txt_mail.getText().contains(".")){
           JOptionPane.showMessageDialog(null, "Debe ingresar un mail correcto!", "Error", JOptionPane.OK_OPTION);
            getTxt_mail().requestFocus();
           valida = false;
       }else if(getCmb_barrio().getSelectedItem().toString().equalsIgnoreCase("Seleccionar")){
           JOptionPane.showMessageDialog(null, "Debe seleccionar un barrio!", "Error", JOptionPane.OK_OPTION);
           valida = false;
       }else if(getCmb_profesion().getSelectedItem().toString().equalsIgnoreCase("Seleccionar")){
           JOptionPane.showMessageDialog(null, "Debe seleccionar una profesión!", "Error", JOptionPane.OK_OPTION);
           valida = false;
       }else if(getCmb_motivo_socio().getSelectedItem().toString().equalsIgnoreCase("Seleccionar")){
           JOptionPane.showMessageDialog(null, "Debe seleccionar un motivo de Socio!", "Error", JOptionPane.OK_OPTION);
           valida = false;
       }else if(getCmb_cumpleano_socio().getSelectedItem().toString().equalsIgnoreCase("Seleccionar")){
           JOptionPane.showMessageDialog(null, "Debe seleccionar si desea ser avisado de cumpleaños de amigos", "Error", JOptionPane.OK_OPTION);
           valida = false;
       }else if(getCmb_boliche().getSelectedItem().toString().equalsIgnoreCase("Seleccionar")){
           JOptionPane.showMessageDialog(null, "Debe seleccionar un Boliche", "Error", JOptionPane.OK_OPTION);
           valida = false;
       }else if(!txt_telefono.toString().equalsIgnoreCase("")){
       try{
            Double.parseDouble(getTxt_telefono().getText().toString());
        }catch(Exception e){
            JOptionPane.showMessageDialog(null, "El teléfono debe ser numérico", "Error", JOptionPane.OK_OPTION);
                getTxt_telefono().setText("");
           valida = false;
           return valida;
           }
        }
       if(!txt_legajo.toString().equalsIgnoreCase("")){
       try{
            Double.parseDouble(getTxt_legajo().getText().toString());
        }catch(Exception e){
            JOptionPane.showMessageDialog(null, "El legajo debe ser numérico", "Error", JOptionPane.OK_OPTION);
                getTxt_legajo().setText("");
           valida = false;
           return valida;
           }
        }
        if(socio == null){
            Boliche b = (Boliche)getCmb_boliche().getSelectedItem();
            System.out.println(getTxt_legajo().getText().toString());
            System.out.println(b.getId());

            if(getSocioBussines().checkLegajoYBoliche(getTxt_legajo().getText().toString(),
                    (Boliche)getCmb_boliche().getSelectedItem())==false ){
                JOptionPane.showMessageDialog(null, "El legajo ya existe", "Error", JOptionPane.OK_OPTION);
                getTxt_legajo().setText("");
                valida = false;
                return valida;
            }
        }else{
            if(socio.getLegajo().compareTo(txt_legajo.getText()) != 0){
                if( getSocioBussines().checkLegajo(getTxt_legajo().getText().toString())==false ){
                    JOptionPane.showMessageDialog(null, "El legajo ya existe", "Error", JOptionPane.OK_OPTION);
                    valida = false;
                    getTxt_legajo().setText(socio.getLegajo());
                    return valida;
                }
            }
        }
       return valida;
    }

    /** Creates new form Example */
    public CargarSocio() {
        initComponents();
        this.setVisible(false);
        rbt_femenino.setSelected(false);
        rbt_masculino.setSelected(false);
        cargarCombos();
        this.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblNombre = new javax.swing.JLabel();
        lblApellido = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        rbt_masculino = new javax.swing.JRadioButton();
        rbt_femenino = new javax.swing.JRadioButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        btn_siguiente = new java.awt.Button();
        txt_nombre = new java.awt.TextField();
        txt_apellido = new java.awt.TextField();
        txt_telefono = new java.awt.TextField();
        txt_direccion = new java.awt.TextField();
        cmb_barrio = new javax.swing.JComboBox();
        txt_mail = new java.awt.TextField();
        cmb_motivo_socio = new javax.swing.JComboBox();
        cmb_profesion = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        date_fecha_nacimiento = new com.toedter.calendar.JDateChooser();
        cmb_boliche = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        txt_legajo = new java.awt.TextField();
        cmb_cumpleano_socio = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Registrar Socio");

        lblNombre.setText("Cliente");

        lblApellido.setText("Nombre");

        jLabel3.setText("Apellido");
        jLabel3.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);

        jLabel4.setText("Teléfono");

        jLabel5.setText("Dirección");

        jLabel6.setText("Barrio");

        jLabel8.setText("Mail");

        rbt_masculino.setText("Masculino");
        rbt_masculino.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbt_masculinoActionPerformed(evt);
            }
        });

        rbt_femenino.setText("Femenino");
        rbt_femenino.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbt_femeninoActionPerformed(evt);
            }
        });

        jLabel9.setText("Sexo");

        jLabel10.setText("Datos Socio");
        jLabel10.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        jLabel11.setText("Motivo Socio");

        jLabel12.setText("Datos Personales");

        jLabel14.setText("Profesión");

        btn_siguiente.setLabel("Siguiente");
        btn_siguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_siguienteActionPerformed(evt);
            }
        });

        txt_nombre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txt_nombreActionPerformed(evt);
            }
        });

        txt_apellido.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));

        txt_telefono.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txt_telefonoFocusLost(evt);
            }
        });

        cmb_barrio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmb_barrio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_barrioActionPerformed(evt);
            }
        });

        cmb_motivo_socio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmb_motivo_socio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_motivo_socioActionPerformed(evt);
            }
        });

        cmb_profesion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmb_profesion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_profesionActionPerformed(evt);
            }
        });

        jLabel1.setText("Fecha Nac.");

        cmb_boliche.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmb_boliche.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmb_bolicheActionPerformed(evt);
            }
        });

        jLabel2.setText("Nombre");

        jLabel7.setText("Datos del Boliche al que se asociará");

        jLabel15.setText("Legajo");

        cmb_cumpleano_socio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel13.setText("Avisar Cumpleaños");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(665, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btn_siguiente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addContainerGap(686, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel15)
                                    .addComponent(lblApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txt_apellido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(txt_nombre, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(txt_legajo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(cmb_profesion, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(txt_telefono, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(rbt_masculino)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(rbt_femenino))
                                    .addComponent(txt_direccion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(txt_mail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(cmb_barrio, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(date_fecha_nacimiento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addComponent(jLabel14)
                            .addComponent(jLabel6))
                        .addGap(145, 145, 145)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10)
                            .addComponent(jLabel7)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cmb_cumpleano_socio, 0, 123, Short.MAX_VALUE)
                            .addComponent(cmb_boliche, 0, 123, Short.MAX_VALUE)
                            .addComponent(cmb_motivo_socio, 0, 123, Short.MAX_VALUE))
                        .addGap(38, 38, 38))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblNombre)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jLabel12))
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(txt_legajo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(cmb_motivo_socio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txt_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txt_apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(rbt_masculino)
                            .addComponent(rbt_femenino))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addGap(16, 16, 16)
                                .addComponent(jLabel5)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel8))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txt_telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txt_direccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txt_mail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cmb_cumpleano_socio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel13)))
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(cmb_barrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(cmb_profesion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(date_fecha_nacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(cmb_boliche, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE)
                .addComponent(btn_siguiente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_siguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_siguienteActionPerformed

        if(validarSiguiente()==true){
            if(socio == null){//Socio nuevo
                socio = new Socio();
                setPs(new PreferenciaSocio());
            }else
                setPs(new PreferenciaSocio(socio));
            

            this.setVisible(false);

            //Lleno los atributos del objeto
            getSocio().setLegajo(getTxt_legajo().getText());
            getSocio().setApellido(getTxt_apellido().getText());
            getSocio().setNombre(getTxt_nombre().getText());

            if(getCmb_cumpleano_socio().getSelectedItem().toString().equalsIgnoreCase("SI")){
                getSocio().setAvisarPorCumpleagnos("S");
            }else{
                getSocio().setAvisarPorCumpleagnos("N");
            }
            
            getSocio().setFechaNacimiento(getDate_fecha_nacimiento().getDate());
            if(getRbt_femenino().isSelected()){
                getSocio().setSexo("F");
            }else{
                getSocio().setSexo("M");
            }
            getSocio().setTelefono(getTxt_telefono().getText());
            getSocio().setDireccion(getTxt_direccion().getText());
            getSocio().setMail(getTxt_mail().getText());
            getSocio().setBarrio((Barrio)getCmb_barrio().getSelectedItem());
            getSocio().setEstudio((Profesion)getCmb_profesion().getSelectedItem());
            getSocio().setRazonSocio(getCmb_motivo_socio().getSelectedItem().toString());
            getSocio().setBoliche((Boliche)getCmb_boliche().getSelectedItem());
            getPs().setSocio(getSocio());

            /*if(isEdit){
                ps.setIsEdit(true);
            }*/


            getPs().setVisible(true);
        }

    }//GEN-LAST:event_btn_siguienteActionPerformed

    private void rbt_masculinoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbt_masculinoActionPerformed
        
        if(getRbt_femenino().isSelected()){
            getRbt_femenino().setSelected(false);
                    }
    }//GEN-LAST:event_rbt_masculinoActionPerformed

    private void rbt_femeninoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbt_femeninoActionPerformed
        if(getRbt_masculino().isSelected()){
            getRbt_masculino().setSelected(false);
                    }
    }//GEN-LAST:event_rbt_femeninoActionPerformed

    private void txt_nombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt_nombreActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txt_nombreActionPerformed

    private void cmb_motivo_socioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_motivo_socioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmb_motivo_socioActionPerformed

    private void txt_telefonoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txt_telefonoFocusLost
     
        
    }//GEN-LAST:event_txt_telefonoFocusLost

    private void cmb_barrioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_barrioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmb_barrioActionPerformed

    private void cmb_profesionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_profesionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmb_profesionActionPerformed

    private void cmb_bolicheActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_bolicheActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmb_bolicheActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CargarSocio().setVisible(true);
            }
        });
    }

    private void cargarCombos(){
        //Carga de combo de motivos socio
        getCmb_motivo_socio().removeAllItems();
        getCmb_motivo_socio().addItem("Seleccionar");
        getCmb_motivo_socio().addItem("CONSUMIDOR");
        getCmb_motivo_socio().addItem("CONVOCANTE");
        getCmb_motivo_socio().addItem("RELEVANTE");

        //Carga de combo de avisar cumpleaños
        getCmb_cumpleano_socio().removeAllItems();
        getCmb_cumpleano_socio().addItem("Seleccionar");
        getCmb_cumpleano_socio().addItem("SI");
        getCmb_cumpleano_socio().addItem("NO");

        //Carga de combo de barrios
        getCmb_barrio().removeAllItems();
        getCmb_barrio().addItem("Seleccionar");
        Barrio[] barrios = getGestor().getBarrios();
        for(int i=0;i<barrios.length;i++){
            getCmb_barrio().addItem(barrios[i]);
        }

        //Carga de combo de Profesiones
        getCmb_profesion().removeAllItems();
        getCmb_profesion().addItem("Seleccionar");
        Profesion[] profesion = getGestor().getProfesion();
        for(int i = 0; i<profesion.length;i++){
            getCmb_profesion().addItem(profesion[i]);
        }

        //Carga de combo de Boliches
        getCmb_boliche().removeAllItems();
        getCmb_boliche().addItem("Seleccionar");
        Boliche[] boliche = getGestor().getBoliche();
        for(int i = 0; i<boliche.length;i++){
            getCmb_boliche().addItem(boliche[i]);
        }
    }


    private ManagerSocio gestor = new ManagerSocio();
    private PreferenciaSocio ps;

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private java.awt.Button btn_siguiente;
    private javax.swing.JComboBox cmb_barrio;
    private javax.swing.JComboBox cmb_boliche;
    private javax.swing.JComboBox cmb_cumpleano_socio;
    private javax.swing.JComboBox cmb_motivo_socio;
    private javax.swing.JComboBox cmb_profesion;
    private com.toedter.calendar.JDateChooser date_fecha_nacimiento;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel lblApellido;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JRadioButton rbt_femenino;
    private javax.swing.JRadioButton rbt_masculino;
    private java.awt.TextField txt_apellido;
    private java.awt.TextField txt_direccion;
    private java.awt.TextField txt_legajo;
    private java.awt.TextField txt_mail;
    private java.awt.TextField txt_nombre;
    private java.awt.TextField txt_telefono;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the socioBussines
     */
    public SocioBussines getSocioBussines() {
        return socioBussines;
    }

    /**
     * @param socioBussines the socioBussines to set
     */
    public void setSocioBussines(SocioBussines socioBussines) {
        this.socioBussines = socioBussines;
    }

    /**
     * @return the gestor
     */
    public ManagerSocio getGestor() {
        return gestor;
    }

    /**
     * @param gestor the gestor to set
     */
    public void setGestor(ManagerSocio gestor) {
        this.gestor = gestor;
    }

    /**
     * @return the ps
     */
    public PreferenciaSocio getPs() {
        return ps;
    }

    /**
     * @param ps the ps to set
     */
    public void setPs(PreferenciaSocio ps) {
        this.ps = ps;
    }

    /**
     * @return the btn_siguiente
     */
    public java.awt.Button getBtn_siguiente() {
        return btn_siguiente;
    }

    /**
     * @param btn_siguiente the btn_siguiente to set
     */
    public void setBtn_siguiente(java.awt.Button btn_siguiente) {
        this.btn_siguiente = btn_siguiente;
    }

    /**
     * @return the cmb_barrio
     */
    public javax.swing.JComboBox getCmb_barrio() {
        return cmb_barrio;
    }

    /**
     * @param cmb_barrio the cmb_barrio to set
     */
    public void setCmb_barrio(javax.swing.JComboBox cmb_barrio) {
        this.cmb_barrio = cmb_barrio;
    }

    /**
     * @return the cmb_boliche
     */
    public javax.swing.JComboBox getCmb_boliche() {
        return cmb_boliche;
    }

    /**
     * @param cmb_boliche the cmb_boliche to set
     */
    public void setCmb_boliche(javax.swing.JComboBox cmb_boliche) {
        this.cmb_boliche = cmb_boliche;
    }

    /**
     * @return the cmb_cumpleano_socio
     */
    public javax.swing.JComboBox getCmb_cumpleano_socio() {
        return cmb_cumpleano_socio;
    }

    /**
     * @param cmb_cumpleano_socio the cmb_cumpleano_socio to set
     */
    public void setCmb_cumpleano_socio(javax.swing.JComboBox cmb_cumpleano_socio) {
        this.cmb_cumpleano_socio = cmb_cumpleano_socio;
    }

    /**
     * @return the cmb_motivo_socio
     */
    public javax.swing.JComboBox getCmb_motivo_socio() {
        return cmb_motivo_socio;
    }

    /**
     * @param cmb_motivo_socio the cmb_motivo_socio to set
     */
    public void setCmb_motivo_socio(javax.swing.JComboBox cmb_motivo_socio) {
        this.cmb_motivo_socio = cmb_motivo_socio;
    }

    /**
     * @return the cmb_profesion
     */
    public javax.swing.JComboBox getCmb_profesion() {
        return cmb_profesion;
    }

    /**
     * @param cmb_profesion the cmb_profesion to set
     */
    public void setCmb_profesion(javax.swing.JComboBox cmb_profesion) {
        this.cmb_profesion = cmb_profesion;
    }

    /**
     * @return the date_fecha_nacimiento
     */
    public com.toedter.calendar.JDateChooser getDate_fecha_nacimiento() {
        return date_fecha_nacimiento;
    }

    /**
     * @param date_fecha_nacimiento the date_fecha_nacimiento to set
     */
    public void setDate_fecha_nacimiento(com.toedter.calendar.JDateChooser date_fecha_nacimiento) {
        this.date_fecha_nacimiento = date_fecha_nacimiento;
    }

    /**
     * @return the jLabel1
     */
    public javax.swing.JLabel getjLabel1() {
        return jLabel1;
    }

    /**
     * @param jLabel1 the jLabel1 to set
     */
    public void setjLabel1(javax.swing.JLabel jLabel1) {
        this.jLabel1 = jLabel1;
    }

    /**
     * @return the jLabel10
     */
    public javax.swing.JLabel getjLabel10() {
        return jLabel10;
    }

    /**
     * @param jLabel10 the jLabel10 to set
     */
    public void setjLabel10(javax.swing.JLabel jLabel10) {
        this.jLabel10 = jLabel10;
    }

    /**
     * @return the jLabel11
     */
    public javax.swing.JLabel getjLabel11() {
        return jLabel11;
    }

    /**
     * @param jLabel11 the jLabel11 to set
     */
    public void setjLabel11(javax.swing.JLabel jLabel11) {
        this.jLabel11 = jLabel11;
    }

    /**
     * @return the jLabel12
     */
    public javax.swing.JLabel getjLabel12() {
        return jLabel12;
    }

    /**
     * @param jLabel12 the jLabel12 to set
     */
    public void setjLabel12(javax.swing.JLabel jLabel12) {
        this.jLabel12 = jLabel12;
    }

    /**
     * @return the jLabel13
     */
    public javax.swing.JLabel getjLabel13() {
        return jLabel13;
    }

    /**
     * @param jLabel13 the jLabel13 to set
     */
    public void setjLabel13(javax.swing.JLabel jLabel13) {
        this.jLabel13 = jLabel13;
    }

    /**
     * @return the jLabel14
     */
    public javax.swing.JLabel getjLabel14() {
        return jLabel14;
    }

    /**
     * @param jLabel14 the jLabel14 to set
     */
    public void setjLabel14(javax.swing.JLabel jLabel14) {
        this.jLabel14 = jLabel14;
    }

    /**
     * @return the jLabel15
     */
    public javax.swing.JLabel getjLabel15() {
        return jLabel15;
    }

    /**
     * @param jLabel15 the jLabel15 to set
     */
    public void setjLabel15(javax.swing.JLabel jLabel15) {
        this.jLabel15 = jLabel15;
    }

    /**
     * @return the jLabel2
     */
    public javax.swing.JLabel getjLabel2() {
        return jLabel2;
    }

    /**
     * @param jLabel2 the jLabel2 to set
     */
    public void setjLabel2(javax.swing.JLabel jLabel2) {
        this.jLabel2 = jLabel2;
    }

    /**
     * @return the jLabel3
     */
    public javax.swing.JLabel getjLabel3() {
        return jLabel3;
    }

    /**
     * @param jLabel3 the jLabel3 to set
     */
    public void setjLabel3(javax.swing.JLabel jLabel3) {
        this.jLabel3 = jLabel3;
    }

    /**
     * @return the jLabel4
     */
    public javax.swing.JLabel getjLabel4() {
        return jLabel4;
    }

    /**
     * @param jLabel4 the jLabel4 to set
     */
    public void setjLabel4(javax.swing.JLabel jLabel4) {
        this.jLabel4 = jLabel4;
    }

    /**
     * @return the jLabel5
     */
    public javax.swing.JLabel getjLabel5() {
        return jLabel5;
    }

    /**
     * @param jLabel5 the jLabel5 to set
     */
    public void setjLabel5(javax.swing.JLabel jLabel5) {
        this.jLabel5 = jLabel5;
    }

    /**
     * @return the jLabel6
     */
    public javax.swing.JLabel getjLabel6() {
        return jLabel6;
    }

    /**
     * @param jLabel6 the jLabel6 to set
     */
    public void setjLabel6(javax.swing.JLabel jLabel6) {
        this.jLabel6 = jLabel6;
    }

    /**
     * @return the jLabel7
     */
    public javax.swing.JLabel getjLabel7() {
        return jLabel7;
    }

    /**
     * @param jLabel7 the jLabel7 to set
     */
    public void setjLabel7(javax.swing.JLabel jLabel7) {
        this.jLabel7 = jLabel7;
    }

    /**
     * @return the jLabel8
     */
    public javax.swing.JLabel getjLabel8() {
        return jLabel8;
    }

    /**
     * @param jLabel8 the jLabel8 to set
     */
    public void setjLabel8(javax.swing.JLabel jLabel8) {
        this.jLabel8 = jLabel8;
    }

    /**
     * @return the jLabel9
     */
    public javax.swing.JLabel getjLabel9() {
        return jLabel9;
    }

    /**
     * @param jLabel9 the jLabel9 to set
     */
    public void setjLabel9(javax.swing.JLabel jLabel9) {
        this.jLabel9 = jLabel9;
    }

    /**
     * @return the lblApellido
     */
    public javax.swing.JLabel getLblApellido() {
        return lblApellido;
    }

    /**
     * @param lblApellido the lblApellido to set
     */
    public void setLblApellido(javax.swing.JLabel lblApellido) {
        this.lblApellido = lblApellido;
    }

    /**
     * @return the lblNombre
     */
    public javax.swing.JLabel getLblNombre() {
        return lblNombre;
    }

    /**
     * @param lblNombre the lblNombre to set
     */
    public void setLblNombre(javax.swing.JLabel lblNombre) {
        this.lblNombre = lblNombre;
    }

    /**
     * @return the rbt_femenino
     */
    public javax.swing.JRadioButton getRbt_femenino() {
        return rbt_femenino;
    }

    /**
     * @param rbt_femenino the rbt_femenino to set
     */
    public void setRbt_femenino(javax.swing.JRadioButton rbt_femenino) {
        this.rbt_femenino = rbt_femenino;
    }

    /**
     * @return the rbt_masculino
     */
    public javax.swing.JRadioButton getRbt_masculino() {
        return rbt_masculino;
    }

    /**
     * @param rbt_masculino the rbt_masculino to set
     */
    public void setRbt_masculino(javax.swing.JRadioButton rbt_masculino) {
        this.rbt_masculino = rbt_masculino;
    }

    /**
     * @return the txt_apellido
     */
    public java.awt.TextField getTxt_apellido() {
        return txt_apellido;
    }

    /**
     * @param txt_apellido the txt_apellido to set
     */
    public void setTxt_apellido(java.awt.TextField txt_apellido) {
        this.txt_apellido = txt_apellido;
    }

    /**
     * @return the txt_direccion
     */
    public java.awt.TextField getTxt_direccion() {
        return txt_direccion;
    }

    /**
     * @param txt_direccion the txt_direccion to set
     */
    public void setTxt_direccion(java.awt.TextField txt_direccion) {
        this.txt_direccion = txt_direccion;
    }

    /**
     * @return the txt_legajo
     */
    public java.awt.TextField getTxt_legajo() {
        return txt_legajo;
    }

    /**
     * @param txt_legajo the txt_legajo to set
     */
    public void setTxt_legajo(java.awt.TextField txt_legajo) {
        this.txt_legajo = txt_legajo;
    }

    /**
     * @return the txt_mail
     */
    public java.awt.TextField getTxt_mail() {
        return txt_mail;
    }

    /**
     * @param txt_mail the txt_mail to set
     */
    public void setTxt_mail(java.awt.TextField txt_mail) {
        this.txt_mail = txt_mail;
    }

    /**
     * @return the txt_nombre
     */
    public java.awt.TextField getTxt_nombre() {
        return txt_nombre;
    }

    /**
     * @param txt_nombre the txt_nombre to set
     */
    public void setTxt_nombre(java.awt.TextField txt_nombre) {
        this.txt_nombre = txt_nombre;
    }

    /**
     * @return the txt_telefono
     */
    public java.awt.TextField getTxt_telefono() {
        return txt_telefono;
    }

    /**
     * @param txt_telefono the txt_telefono to set
     */
    public void setTxt_telefono(java.awt.TextField txt_telefono) {
        this.txt_telefono = txt_telefono;
    }


}
